package com.bwie;

import java.util.ArrayList;
import java.util.List;

public class booklist1 {
    private List<Book> bookList=new ArrayList<>();

    public synchronized Book addBook(Book book){
        bookList.add(book);
        return book;
    }

    public synchronized Book getBook(int index){
        return bookList.get(index);
    }

    public synchronized Book removeBook(int index){
        return bookList.remove(index);
    }

    public void printAll(){
        for (Book book : bookList) {
            System.out.println(book);
        }
    }

    public static void main(String[] args){
        booklist1 booklist2 = new booklist1();
        booklist2.addBook(new Book(1,"aaa","111","aaa"));
        booklist2.addBook(new Book(2,"aaa","111","aaa"));
        booklist2.addBook(new Book(3,"aaa","111","aaa"));

        System.out.println(booklist2.getBook(1));

        booklist2.removeBook(2);
        booklist2.printAll();
    }
}
